<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class user_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
		$this->CI = get_instance();
	}
	
	function insert($data)
	{
		$this->db->insert('user',$data);
	}
	
	function update($id, $data)
	{
		$this->db->where('id_user',$id);
		$this->db->update('user',$data);
	}
	
	function delete($id)
	{
		$this->db->where('id_user', $id);
		$this->db->delete('user');
	}
	
	function get_user()
	{
		$this->db->select("*");
		$this->db->from('user');
		$this->db->where("STATUS > 0 ");
		$query = $this->db->get();
		return $query;
	}
	
	//list flexy
	function get_data_user()
	{
		//Select table name
		$table_name = "user";
		
		//Build contents query
		$this->db->select('*')->from($table_name);
        $this->CI->flexigrid->build_query();
		
		//Get contents
		$return['records'] = $this->db->get();
		
		//Build count query
		$this->db->select('*')->from($table_name);
        $this->CI->flexigrid->build_query(FALSE);
		
		$return['record_count'] = $this->db->count_all_results();
	
		//Return all
		return $return;
	}
	
	function selectone($id)
	{
		$this->db->select("*");
		$this->db->from('user');
		$this->db->where('id_user',$id);
		$query = $this->db->get();
		return $query;
	}
	

	
}

?>